# -*- coding: utf-8 -*-
from dao.db import db
from datetime import datetime

class ClassSubjectTeacher(db.Model):
    __tablename__ = 'class_subject_teacher'
    id = db.Column(db.BigInteger, primary_key=True)
    class_id = db.Column(db.BigInteger, db.ForeignKey('classes.id', ondelete='CASCADE'), nullable=False, comment='班级ID')
    subject = db.Column(db.String(50), nullable=False, comment='学科名称')
    teacher_id = db.Column(db.BigInteger, db.ForeignKey('teachers.id', ondelete='CASCADE'), nullable=False, comment='任课老师ID')
    created_at = db.Column(db.DateTime, default=datetime.now, comment='创建时间')
    updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')

    # 关系映射
    class_info = db.relationship('Class', backref=db.backref('subject_teachers', cascade='all, delete-orphan'))
    teacher_info = db.relationship('Teacher', backref=db.backref('subject_classes', cascade='all, delete-orphan'))